import { forwardRef, useImperativeHandle, useRef } from "react";

export interface Ref {
  focus: () => void;
}
const SearchInput = forwardRef<Ref>((props, ref) => {
  const realInputRef = useRef<HTMLInputElement>(null);
  useImperativeHandle(
    ref,
    () => ({
      focus() {
        realInputRef.current?.focus();
      }
    }),
    []
  );

  return <input ref={realInputRef} placeholder="找什么呢？" />;
});

export default SearchInput;
